package pure.csw.activemq.ack;

import pure.csw.common.ActiveMqUtils;
import pure.csw.common.Constant;

import javax.jms.*;

public class Producer {
    public static void main(String[] args) throws JMSException, InterruptedException {
        Connection connection = ActiveMqUtils.getConnection();
        connection.start();
        //获取一次会话
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue(Constant.QUEUENAME);
        MessageProducer producer = session.createProducer(queue);
        for (int i = 0; i< 3; i++) {
            TextMessage message = session.createTextMessage();
            message.setText("生产者开启客户端签收：第"+i+"个消息");
            producer.send(message);
        }
        session.close();
        producer.close();
        connection.close();
        System.out.println("程序结束");
    }
}
